/*
* jlb
*/
package com.jlb.item.ctrl;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;
import java.util.HashMap;

import com.jlb.core.entity.BeanRet;
import com.jlb.core.entity.Page;
import com.jlb.core.tools.redis.RedisUtils;
import com.jlb.item.entity.ItemPayMethodPrice;
import com.jlb.item.service.ItemPayMethodPriceSV;

/**
 * 支付方式价格 控制器
 *
 * @author jlb
 */
@RestController
@RequestMapping("/itemPayMethodPrice")
@Slf4j
@Api(value = "支付方式价格控制器", description = "支付方式价格控制器")
public class ItemPayMethodPriceCtrl {

    @Resource
    protected RedisUtils redisUtils;

    @Resource
    private ItemPayMethodPriceSV itemPayMethodPriceSV;

    /**
     * 查询ItemPayMethodPrice一个详情信息
     *
     * @param id
     * @param itemCode 产品编码
     * @return BeanRet
     */
    @ApiOperation(value = "查询ItemPayMethodPrice一个详情信息", notes = "查询ItemPayMethodPrice一个详情信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "", dataType = "java.lang.Long", paramType = "query"),
            @ApiImplicitParam(name = "itemCode", value = "产品编码", dataType = "java.lang.String", paramType = "query")
    })
    @GetMapping(value = "/load")
    @ResponseBody
    public BeanRet load(Long id, String itemCode) {
        if (id == null) {
            return null;
        }
        if (itemCode == null) {
            return null;
        }
        ItemPayMethodPrice itemPayMethodPrice = itemPayMethodPriceSV.load(id, itemCode);
        log.info(JSON.toJSONString(itemPayMethodPrice));
        return BeanRet.create(true, "查询成功", itemPayMethodPrice);
    }


    /**
     * 根据条件id查询ItemPayMethodPrice一个详情信息
     *
     * @param id
     * @return BeanRet
     */
    @ApiOperation(value = "查询ItemPayMethodPrice一个详情信息", notes = "查询ItemPayMethodPrice一个详情信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "", dataType = "java.lang.Long", paramType = "path")
    })
    @GetMapping(value = "/load/id/{id}")
    @ResponseBody
    public BeanRet loadById(@PathVariable Long id) {
        if (id == null) {
            return null;
        }
        ItemPayMethodPrice itemPayMethodPrice = itemPayMethodPriceSV.loadById(id);
        log.info(JSON.toJSONString(itemPayMethodPrice));
        return BeanRet.create(true, "查询成功", itemPayMethodPrice);
    }

    /**
     * 根据条件itemCode查询ItemPayMethodPrice一个详情信息
     *
     * @param itemCode 产品编码
     * @return BeanRet
     */
    @ApiOperation(value = "查询ItemPayMethodPrice一个详情信息", notes = "查询ItemPayMethodPrice一个详情信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "itemCode", value = "产品编码", dataType = "java.lang.String", paramType = "path")
    })
    @GetMapping(value = "/load/itemCode/{itemCode}")
    @ResponseBody
    public BeanRet loadByItemCode(@PathVariable String itemCode) {
        if (itemCode == null) {
            return null;
        }
        ItemPayMethodPrice itemPayMethodPrice = itemPayMethodPriceSV.loadByItemCode(itemCode);
        log.info(JSON.toJSONString(itemPayMethodPrice));
        return BeanRet.create(true, "查询成功", itemPayMethodPrice);
    }


    /**
     * 查询ItemPayMethodPrice信息集合
     *
     * @return 分页对象
     */
    @ApiOperation(value = "查询ItemPayMethodPrice信息集合", notes = "查询ItemPayMethodPrice信息集合")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    })
    @GetMapping(value = "/list")
    @ResponseBody
    public BeanRet list(@ApiIgnore ItemPayMethodPrice itemPayMethodPrice, Integer curPage, Integer pageSize) {
        Page<ItemPayMethodPrice> page = new Page<ItemPayMethodPrice>(pageSize, curPage);
        List<ItemPayMethodPrice> itemPayMethodPrices = itemPayMethodPriceSV.list(itemPayMethodPrice, page.genRowStart(), page.getPageSize());
        page.setVoList(itemPayMethodPrices);
        int total = itemPayMethodPriceSV.count(itemPayMethodPrice);
        page.setTotalRow(total);

        return BeanRet.create(true, "查询成功", page);

    }


    /**
     * 查询ItemPayMethodPrice信息集合
     *
     * @return 分页对象
     */
    @ApiOperation(value = "查询ItemPayMethodPrice信息集合", notes = "查询ItemPayMethodPrice信息集合")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
            @ApiImplicitParam(name = "id", value = "", paramType = "query"),
            @ApiImplicitParam(name = "itemCode", value = "产品编码", paramType = "query")
    })
    @GetMapping(value = "/list/by")
    @ResponseBody
    public BeanRet listByPk(Long id, String itemCode, Integer curPage, Integer pageSize) {
        Page<ItemPayMethodPrice> page = new Page<ItemPayMethodPrice>(pageSize, curPage);
        List<ItemPayMethodPrice> itemPayMethodPrices = itemPayMethodPriceSV.list(id, itemCode, page.genRowStart(), page.getPageSize());
        page.setVoList(itemPayMethodPrices);
        int total = itemPayMethodPriceSV.count(id, itemCode);
        page.setTotalRow(total);

        return BeanRet.create(true, "查询成功", page);
    }

    /**
     * 统计ItemPayMethodPrice信息数量根据主键
     *
     * @return 总条数
     */
    @ApiOperation(value = " 统计ItemPayMethodPrice信息数量根据主键", notes = " 统计ItemPayMethodPrice信息数量根据主键")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "", paramType = "query"),
            @ApiImplicitParam(name = "itemCode", value = "产品编码", paramType = "query")
    })
    @GetMapping(value = "/count/by")
    @ResponseBody
    public Integer count(Long id, String itemCode) {
        return itemPayMethodPriceSV.count(id, itemCode);
    }

    /**
     * 统计ItemPayMethodPrice信息数量
     *
     * @return 总条数
     */
    @ApiOperation(value = "统计ItemPayMethodPrice信息数量", notes = "统计ItemPayMethodPrice信息数量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "", paramType = "query"),
            @ApiImplicitParam(name = "itemCode", value = "产品编码", paramType = "query"),
            @ApiImplicitParam(name = "payMethodCode", value = "支付方式编码", paramType = "query"),
            @ApiImplicitParam(name = "payMethodName", value = "支付方式", paramType = "query"),
            @ApiImplicitParam(name = "price", value = "价格", paramType = "query")
    })
    @GetMapping(value = "/count")
    @ResponseBody
    public Integer count(@ApiIgnore ItemPayMethodPrice itemPayMethodPrice) {
        if (itemPayMethodPrice == null) {
            return itemPayMethodPriceSV.count(new HashMap());
        } else {
            return itemPayMethodPriceSV.count(itemPayMethodPrice);
        }
    }


    /**
     * 创建ItemPayMethodPrice
     *
     * @return BeanRet
     */
    @ApiOperation(value = "创建ItemPayMethodPrice", notes = "创建ItemPayMethodPrice")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "payMethodCode", value = "支付方式编码", paramType = "query"),
            @ApiImplicitParam(name = "payMethodName", value = "支付方式", paramType = "query"),
            @ApiImplicitParam(name = "price", value = "价格", paramType = "query")
    })
    @PostMapping("/build")
    @ResponseBody
    public BeanRet build(@ApiIgnore ItemPayMethodPrice itemPayMethodPrice) {
        itemPayMethodPriceSV.save(itemPayMethodPrice);
        return BeanRet.create(true, "创建成功", itemPayMethodPrice);
    }


    /**
     * 修改ItemPayMethodPrice
     *
     * @return BeanRet
     */
    @ApiOperation(value = "修改ItemPayMethodPrice", notes = "修改ItemPayMethodPrice")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "", paramType = "query"),
            @ApiImplicitParam(name = "itemCode", value = "产品编码", paramType = "query"),
            @ApiImplicitParam(name = "payMethodCode", value = "支付方式编码", paramType = "query"),
            @ApiImplicitParam(name = "payMethodName", value = "支付方式", paramType = "query"),
            @ApiImplicitParam(name = "price", value = "价格", paramType = "query")
    })
    @PutMapping("/modify")
    @ResponseBody
    public BeanRet modify(@ApiIgnore ItemPayMethodPrice itemPayMethodPrice) {
        itemPayMethodPriceSV.modify(itemPayMethodPrice);
        return BeanRet.create(true, "修改成功", itemPayMethodPrice);
    }

    /**
     * 删除ItemPayMethodPrice
     *
     * @return BeanRet
     */
    @ApiOperation(value = "删除ItemPayMethodPrice", notes = "删除ItemPayMethodPrice")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "", paramType = "query"),
            @ApiImplicitParam(name = "itemCode", value = "产品编码", paramType = "query")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public BeanRet delete(Long id, String itemCode) {
        itemPayMethodPriceSV.delete(id, itemCode);
        return BeanRet.create(true, "删除ItemPayMethodPrice成功");
    }

}
